package com.shakespace.template.extensions

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.widget.Toast

/**
 * [clazz] : target activity
 * [bundle] : bundle data
 */
fun Context.start(clazz: Class<*>, bundle: Bundle? = null) {
    startActivity(Intent(this, clazz).also {
        if (bundle != null) {
            it.putExtra("bundle", bundle)
        }
    })
}

fun Activity.kill() {
    android.os.Process.killProcess(android.os.Process.myPid())
}

fun Context.showToast(msg: String, duration: Int = Toast.LENGTH_SHORT) {
    Toast.makeText(this, msg, duration).show()
}

val Context.orientation: Int
    get() {
        return this.resources.configuration.orientation
    }

val Context.screenWidth
    get() = resources.displayMetrics.widthPixels

val Context.screenHeight
    get() = resources.displayMetrics.heightPixels
